import Foundation
import UIKit

class UserDefaultsManager {
    static let shared = UserDefaultsManager()
   
    
    private init() {}
    
    // 保存String值
    func setString(_ value: String, forKey key: String) {
        UserDefaults.standard.set(value, forKey: key)
    }
    
    func getString(forKey key: String) -> String? {
        let value = UserDefaults.standard.string(forKey: key)
        return value ?? "null"
    }
    
    
    func setInt(_ value: Int, forKey key: String) {
        UserDefaults.standard.set(value, forKey: key)
    }
    
    func getInt(forKey key: String) -> Int {
        let value = UserDefaults.standard.object(forKey: key) as? Int
        return value ?? -1
    }
    
   
    func setBool(_ value: Bool, forKey key: String) {
        UserDefaults.standard.set(value, forKey: key)
    }
    
    
    func getBool(forKey key: String) -> Bool {
        let value = UserDefaults.standard.object(forKey: key) as? Bool
        return value ?? false
    }
     
}


